<template>
  <div>
    <el-dialog
      :title="'评论详细内容'"
      :close-on-click-modal="false"
      :visible.sync="visible"
    >
      <el-form
        :model="dataForm"
        ref="dataForm"
        @keyup.enter.native="dataFormSubmit()"
        label-width="140px"
      >
        <el-form-item label="评论内容" prop="content">
          <el-input
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4 }"
            placeholder="请输入内容"
            v-model="dataForm.content"
          >
          </el-input>
        </el-form-item>

        <el-form-item label="评论图片" prop="resources">
          <template>
            <img
              v-for="(url, index) in arr"
              :key="index"
              :src="url"
              style="width: 15%; height: 15%"
            />
          </template>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "RenrenFastVueCommentUpdate",

  data() {
    return {
      visible: false,
      dataForm: {
        spuCommentId: 0,
        content: "",
        resources: ""
      },
      arr: []
    };
  },

  mounted() {},

  methods: {
    init(id) {
      this.dataForm.spuCommentId = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].resetFields();
        if (this.dataForm.spuCommentId) {
          this.$http({
            url: this.$http.adornUrl(
              `/product/spucomment/info/${this.dataForm.spuCommentId}`
            ),
            method: "get",
            params: this.$http.adornParams()
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.dataForm.content = data.spuComment.content;
              this.dataForm.resources = data.spuComment.resources;
              this.arr = this.dataForm.resources.split(",");
            }
          });
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped></style>
